home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4949 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: oasis.novia.net!not-for-mail
  2. From: nicatt@oasis.novia.net (Nicatt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: atof/atoi
  5. Date: 11 Feb 1996 15:12:09 GMT
  6. Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
  7. Message-ID: <4fl109$31g@nntp.novia.net>
  8. References: <4fihpp$j5q@nntp.novia.net>
  9. NNTP-Posting-Host: oasis.novia.net
  10. X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
  11.  
  12. Nicatt (nicatt@oasis.novia.net) wrote:
  13.  
  14. The question was answered by e-mail.  Thank you.  Perhaps I went
  15. thru the FAQ too quickly.  I will look again but I didn't see it
  16. the first time thru.
  17. Nicatt
  18.  
  19.  
  20. : I am a rookie.
  21. : I have been through the faq and three C books and cannot find *how*
  22. : to use atof/atoi.  Each mentions them and their purpose, but none explains 
  23. : how to use them.
  24. : I wrote a program that works fine.  However, one of the requirements
  25. : is to trap for alpha characters.  If I use "gets", my Y/N response
  26. : prior to the loop below falls through.  I can define *catch* as a char
  27. : and trap the character after scanf (ex:  catch=getchar();  ) but I have
  28. : not figured how to use that to my advantage to break the loop, reask for
  29. : the correct value to be entered, and restart the loop at that point.  
  30. : This is an internet class and the instructor said to use atof.  
  31. : The question is, how do you use atof?
  32. : for(count=0; count<STUDENTS; count++)
  33. :   { printf("\nWhat is student %i's grade average ", (count+1));
  34. :     for(count2=0; count2<GRADES; count2++)
  35. :       { printf("in class number %i?\n ", (count2+1));
  36. :         scanf(" %f", &number);
  37. :         grades[count][count2]=number;
  38. :         printf("You entered %.3f \n\n", grades[count][count2]);
  39. :   }   }
  40. : Thank you in advance for any assistance you may render.
  41. : Bob
  42. : nicatt@oasis.novia.net
  43.